<template>
  <van-overlay :show="isShow" @click="maskClick">
    <div class="wrapper">
      <div class="block" @click.stop>
        <div class="close">
          <span class="title">{{title}}</span>
          <van-icon class="icon" @click="maskClick" name="cross" style="margin-right: 0.8rem;" size="1.5rem" />
        </div>
        <van-cell-group>
          <slot></slot>
        </van-cell-group>
      </div>
    </div>
  </van-overlay>
</template>

<script>
export default {
  name: "MyDialog",
  props: {
    isShow: {
      type: Boolean,
      required: true,
      default: false
    },
    title: {
      type: String,
    },
  },  
  emits: ["update:closeDialog"],
  setup(props, context) {

    function maskClick() {
      context.emit("update:closeDialog", false)
    }

    return {
      maskClick
    }
  }
}
</script>

<style lang="scss">
.wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
  }

  .block {
    width: 30rem;
    min-height: 10rem;
    background-color: #fff;
    border-radius: var(--global-border-radius);
    box-sizing: border-box;
    padding: 0.5rem;

    .close {
      width: 100%;
      height: 2rem;
      margin: 0.5rem 0;
      display: flex;
      justify-content: right;
      align-items: center;
      .title {
        height: 100%;
        flex: 1;
        text-align: center;
        font-size: 1.5rem;
        margin-left: 2rem;
      }
      .icon {
        width: 1.5rem;
      }
    }
  }
</style>